import database as DB
import json
import datetime as DT
import random

def writeToFile(fnm, content):
    with open(fnm, "w") as f:
        f.write(content)

ret = {}
dbList = ["user", "student", "volunteer", "class_vol", "stu_vol"]

for dbName in dbList:
    DB.execute("select * from %s;" % (dbName), tuple())
    ret[dbName] = DB.fetchall()

fnm = DT.date.today().isoformat() + '-' + str(random.choice(range(100,1000))) + '.zvms'
writeToFile(fnm, json.dumps(ret))
